<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div>
        <span>输入内容：</span>
        <input type="text" id="content">
        <button id="btn">click to typing!!!</button>
    </div>
    <div>
        <span>文字输出区域</span>
        <div id="writeArea" style="font-size: 20px;border: 1px solid #ccc; line-height: 50px;height: 50px;text-align:center;"></div>
    </div>
    <script src="./lib/jquery.min.js"></script>
    <script>
        window.onload = function () {
            var value = '';
            var i = 0;
            var timer = null;
            var clear = null;
            var writeArea;
            $('#btn').on('click',init);
            function init() {
                value = $('#content').val();
                clear = null;
                writeArea = document.getElementById("writeArea");
                timer = setInterval(show, 200);
            }

            function show() {
                i++;
                var str = value.substring(0, i);
                $('#writeArea').text(str);
                if (i == value.length) {
                    clear = clearInterval(timer);
                    console.log('clear');
                }
            }
        }
    </script>
</body>

</html>